package com.example.demo.util;

import cn.hutool.cron.CronUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.db.ds.DSFactory;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

/**
 * @author BleethNie
 * @version 1.0
 * @date 2020/10/24 15:20
 **/
public class DataBase {
    public static void main(String[] args) throws SQLException {
      CronUtil.start();


    }
    public static void run() throws SQLException {


        DataSource ds1 = DSFactory.get("group_db1");
        List<Entity> student_1 = Db.use(ds1).findAll("student");
        DataSource ds2 = DSFactory.get("group_db2");

        for (int i = 0; i < student_1.size(); i++)  {
            Entity entity = student_1.get(i);
            entity.setTableName("student_1");
        }

        Db.use(ds2).insert(student_1);

        CronUtil.stop();
    }
}
